package com.rwx.myjetpack.base

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.rwx.myjetpack.lifecycle.ILifecycle
import com.rwx.myjetpack.lifecycle.ILifecycleOwner
import com.rwx.myjetpack.lifecycle.LifeState
import com.rwx.myjetpack.lifecycle.LifecycleProvider
import com.rwx.myjetpack.musiclist.MusicListPresenter

/**
 * Created by LH on 2023-05-26.
 * Time: 2023-05-26  15:56
 */
open class BaseFragment:Fragment(),ILifecycleOwner {


    val lifeProvider by lazy {
        LifecycleProvider()
    }





    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        lifeProvider.makeLifeState(LifeState.CREATE)
    }


    override fun onStart() {
        super.onStart()
        lifeProvider.makeLifeState(LifeState.START)
    }

    override fun onResume() {
        super.onResume()
        lifeProvider.makeLifeState(LifeState.RESUME)

    }

    override fun onPause() {
        super.onPause()
        lifeProvider.makeLifeState(LifeState.PAUSE)

    }

    override fun onStop() {
        super.onStop()
        lifeProvider.makeLifeState(LifeState.STOP)
    }

    override fun onDestroy() {
        super.onDestroy()
        lifeProvider.makeLifeState(LifeState.DESTORY)

    }

    override fun getLifecycleProvider(): LifecycleProvider {
        return lifeProvider
    }


}